<%@ page import="search.User" %>
<%@ page import="java.util.List" %>
<%@ page import="search.SearchUser" %>
<%@ page import="search.Recipe" %><%--
  Created by IntelliJ IDEA.
  User: wangx
  Date: 2024/10/26
  Time: 01:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Admin Dashboard</title>
    <link rel="stylesheet" href="chushi/css/admin_style.css">
</head>
<body>
<div class="container">
    <header>
        <h1>Admin Dashboard</h1>
    </header>
    <nav>
        <button id="userManagementBtn">User Management</button>
        <button id="recipeManagementBtn">Recipe Management</button>
    </nav>
    <main>
        <section id="userManagement" class="management-section">
            <h2>User Management</h2>
            <table id="userTable">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>Username</th>
                    <th>Password</th>
                    <th>icoUL</th>
                    <th>Actions</th>
                </tr>
                </thead>
                <tbody></tbody>
            </table>
            <button id="addUserBtn">Add User</button>
        </section>
        <section id="recipeManagement" class="management-section" style="display:none;">
            <h2>Recipe Management</h2>
            <table id="recipeTable">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>Name</th>
                    <th>image</th>
                    <th>Actions</th>
                </tr>
                </thead>
                <tbody></tbody>
            </table>
            <button id="addRecipeBtn">Add Recipe</button>
        </section>
    </main>
</div>
<script>
    let users = [];
    let recipes = [];
    users.push(

    <%
    SearchUser shu=new SearchUser();
    List<User> users=shu.searchAllUser();
    for(User user:users){
    %>

        {
            id: <%=user.getId()%>,
            username: '<%=user.getName()%>',
            password:'<%=user.getPassword()%>',
            icoUL: '<%=user.getIco()%>'
        },
    )
    recipes.push(
    <%
    }
    List<Recipe> recipes=shu.searchAll();
    for(Recipe recipe:recipes){
    %>




        {
            id:<%=recipe.getId()%>,
            title:'<%=recipe.getName()%>',
            category:'<%=recipe.getCategory()%>',
            image: '<%=recipe.getImage()%>',

        },
<%}%>
    )
</script>
<script src="chushi\script\admin_script.js"></script>
</body>
</html>
